<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<link rel="stylesheet" type="text/css" href="../../../Themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="../../../Themes/icon.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/demo.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/common.css">
		<script type="text/javascript" src="../../../JS/jquery.min.js"></script>
		<script type="text/javascript" src="../../../JS/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="../../../JS/common.js"></script>
		<script type="text/javascript" src="../../../JS/SHA-1.js"></script>
	</head>

	<body style="padding:0px">
		<div class="easyui-layout" style="width:100%;height:600px;">
			<div data-options="region:'center'">
				<div>
					<table id="dg" style="width: 100%;" class="table_style">
					</table>
				</div>
			</div>
		</div>
		<div id="toolbar">
		</div>
		<div id="dlg" class="easyui-dialog" closed="true" style="height: 400px;width: 300px;">
			<iframe id="dlg" style="width: 100%;height: 100%;" frameborder="0" scrolling="no"></iframe>
		</div>
	</body>
	<script type="text/javascript">
		var currid = getID();
		var listUrl = "";
		if(currid != undefined) {
			listUrl = RemoteLinkAddress + "/market/contract/list.do?TENANT_ID=" + currid;
		} else {
			listUrl = RemoteLinkAddress + "/market/contract/list.do";
		}
		var content = "";
		//		$("#toolbar").append(content);

		var extratoolbar = [{
			"icon": "icon-longtermcontract",
			"func": "addLongTermContract()",
			"functionname": "新建长期合同"
		}, {
			"icon": "icon-shorttermcontract",
			"func": "addShortTermContract()",
			"functionname": "新建短期合同"
		}];
		for(var i = 0; i < extratoolbar.length; i++) {
			content += "<a href=\"javascript:void(0)\" class=\"easyui-linkbutton\"  iconCls=\"" + extratoolbar[i].icon + "\" plain='true' onclick=\"" + extratoolbar[i].func + "\">" + extratoolbar[i].functionname + "</a>";
		}

		content += AddToolBar(32);
		$("#toolbar").append(content);

		function newdata() {
			var pLocation = "UI/Market/BIContract/BIContractAdd.html?id=-1";
			AddTabIn("新增合同", parent.parent.$("#tabs"), pLocation);
		}

		$('#dg').datagrid({
			url: listUrl,
			toolbar: '#toolbar',
			method: 'get',
			rownumbers: 'true',
			fitColumns: 'true',
			pagination: 'true',
			singleSelect: 'true',
			height: 350,
			columns: [
				[{
					field: 'ORDER_NO',
					title: '合同编号',
					width: '10%',
					align: 'center'
				}, {
					field: 'ID',
					title: 'ID',
					width: '0%',
					align: 'center'
				}, {
					field: 'TENANT_NAME',
					title: '客户名称',
					width: '8%',
					align: 'center'

				}, {
					field: 'SUM',
					title: '合计',
					width: '8%',
					align: 'center',
					formatter: function(value, row, index) {
						if(value) {
							return "￥" + value;
						}
					}
				}, {
					field: 'MARGIN_SUM',
					title: '保证金',
					width: '8%',
					align: 'center',
					formatter: function(value, row, index) {
						if(value) {
							return "￥" + value;
						}
					}

				}, {
					field: "BEGIN_TIME",
					title: "开始日期",
					width: "9%",
					align: 'center'

				}, {
					field: 'END_TIME',
					title: '截至日期',
					width: '9%',
					align: 'center'
				}, {
					field: 'BUSINESS_AREA',
					title: '经营面积',
					width: '9%',
					align: 'center',
					formatter: function(value, row, index) {
						if(value) {
							return value + " m&sup2";
						} else {
							return "无";
						}
					}
				},  {
					field: 'ORDER_TYPE',
					title: '合同期限类型',
					width: '8%',
					align: 'center',
					formatter: function(value, row, index) {
						switch(value) {
							case "0":
								return "短期合同";
								break;
							case "1":
								return "长期合同"
								break;
						}
					}
				}, {
					field: 'STATE',
					title: '合同状态',
					width: '9%',
					align: 'center'
				},
				{
					field: 'ISVERIFY',
					title: '审核状态',
					width: '9%',
					align: 'center',
					formatter: function(value, row, index) {
							return verifyStatus(value,false);
						}
				}]
			],
			onDblClickRow: function(index, row) {
				switch(row.ORDER_TYPE) {
					case "0":
						var pLocation = "UI/Market/BIContract/BIContractListShort.html?ID=" + row.ID;
						AddTabIn("短期合同详细信息", parent.parent.$("#tabs"), pLocation);
						break;
					case "1":
						var pLocation = "UI/Market/BIContract/BIContractListLong.html?ID=" + row.ID;
						AddTabIn("长期合同详细信息", parent.parent.$("#tabs"), pLocation);
						break;
				}

			}
		});
		$('#dg').datagrid('hideColumn', 'ID'); //隐藏第一列


		function dialogOpen() {
			var top = $("#dg").offset().top;
			var left = $("#dg").offset().left + 30;
			$('#dlg').window('open').window('resize', {
				width: '800px',
				height: '450px',
				top: top,
				left: left
			});
		}

		function moreinfo(id) {
			AddDialog.dialog('open');
		}

		//新建长期合同
		function addShortTermContract() {
			var pLocation = "UI/Market/BIContractCreate/BIContractAddShort.html";
			AddTabIn("新建短期合同", parent.parent.$("#tabs"), pLocation);
		}

		//新建短期合同
		function addLongTermContract() {
			var pLocation = "UI/Market/BIContractCreate/BIContractAddLong.html";
			AddTabIn("新建长期合同", parent.parent.$("#tabs"), pLocation);
		}
		
		function redodata() {
			checkAllData("/market/contract/list.do");
		}
	</script>

</html>